const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;
let router = require('./router');
let url = require('url');
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  if(req.url !== "/favicon.ico")
  {
    var pathname = url.parse(req.url).pathname;
    pathname = pathname.replace(/\//,'');
    router[pathname](req,res);
  }
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
  console.log("\n使用GIT 管理版本1");
});